package com.killer.texreader.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.TextView;


import com.killer.texreader.R;
import com.killer.texreader.util.Globals;

import java.util.List;
import java.util.Map;

/**
 * Created by killer on 2016/4/22.
 */
public class stageAdapter extends BaseAdapter {
    private Context context;
    List<Map<String, Object>> values;

    public stageAdapter(Context context, List<Map<String, Object>> valuses) {
        this.context = context;
        this.values = valuses;
    }

    @Override
    public int getCount() {
        return values.size();
    }

    @Override
    public Object getItem(int position) {
        return values.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView==null){
            convertView = LayoutInflater.from(context).inflate(R.layout.setting_grid,null);
            convertView.setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Globals.SCREEN_HEIGHT/8));
        }
        TextView stageNum = (TextView) convertView.findViewById(R.id.stage_num);

        Map<String, Object> map = values.get(position);

        stageNum.setText(map.get("textName").toString());


        return convertView;
    }
}
